import axios from "axios";
import { BASE_URL } from "../Constant";
const USER_BASE_URL = BASE_URL + '/user'
const USER_ORDER_BASE_URL = BASE_URL + '/user-order'
export const loginApi = (data:any) => {
    return axios.post(
        USER_BASE_URL + '/login',
        data
    )
}

export const adminLoginApi = (data:any) => {
    return axios.post(
        USER_BASE_URL + '/adminLogin',
        data
    )
}

export const listOrder = (userName:string) => {
    return axios.get(
        USER_ORDER_BASE_URL + `/list?userName=${userName}`
    )
}

export const count = () => {
    return axios.get(
        USER_BASE_URL + '/count'
    )
}

export const listPage = (start:number,offset:number) => {
    return axios.get(
        USER_BASE_URL + `/listByPage?start=${start}&offset=${offset}`
    )
}

export const charge = (data:any) => {
    return axios.post(
        USER_BASE_URL + '/charge',
        data
    )
}
export function orderList (start:number,offset:number) {
    return axios.get (
        USER_ORDER_BASE_URL + `/pageList?start=${start}&offset=${offset}`
    )
}
export const orderCount = () => {
    return axios.get(
        USER_ORDER_BASE_URL + '/count'
    )
}

export const purchaseApi = (data:any) => {
    return axios.post(
        USER_BASE_URL  + '/purchase',
        data
    )
}

export const reg =(data:any) => {
    return axios.post(
        USER_BASE_URL + '/reg',
        data
    )
}

export const getUser = (userName:string) => {
    return axios.get(
        USER_BASE_URL + `/getUser?userName=${userName}`
    )
}

export const changeApi = (data:any) => {
    return axios.post(
        USER_BASE_URL + '/changeAttr',
        data
    )
}

export const resetPasswd = (data:any) => {
    return axios.post(
        USER_BASE_URL  + '/resetPasswd',
        data
    )
}

export const sendApi = (id:string) => {
    return axios.post(
        USER_ORDER_BASE_URL + '/send',
        {
            id
        }
    )
}

export const reciveApi = (id:string) => {
    return axios.post(
        USER_ORDER_BASE_URL + '/recive',
        {
            id
        }
    )
}